import type {
  LoginState,
  LoginSuccessVo,
  OauthLoginState,
} from '#/auth/login'
import { http } from '@/utils/http/index'

/**
 * 登录
 * @param data
 * @returns Promise<LoginSuccessVo>
 */
export function loginApi(data: LoginState | OauthLoginState) {
  return http.request<LoginSuccessVo>('POST', '/auth/oauth2/token', data, {
    url: '/auth/oauth2/token',
  })
}

/**
 * 获取验证码
 * @param cellphone  手机号码
 * @returns CaptchaVo
 */
export function sendLoginSmsApi(cellphone: string) {
  return http.request<void>('POST', `/app-api/system/oauth2/code/sendLogin/${cellphone}`)
}
